import time

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
# 窗口最大化
driver.maximize_window()

driver.get("https://www.baidu.com/")
# 根据ID定位
# driver.find_element(By.CSS_SELECTOR,"#kw").send_keys("唐朝诡事录")
# driver.find_element(By.CSS_SELECTOR,"#su").click()
# 根据class属性值定位
# driver.find_element(By.CSS_SELECTOR,".nav-search-input").send_keys("软件测试")
# driver.find_element(By.CSS_SELECTOR,".nav-search-btn").click()
# 根据name属性值定位
# driver.find_element(By.CSS_SELECTOR,"[name='wd']").send_keys("selenium")
# driver.find_element(By.CSS_SELECTOR,'[value="百度一下"]').click()
# 根据标签属性定位
# driver.find_element(By.CSS_SELECTOR,"a[href='http://image.baidu.com/']").click()
# 模糊匹配——包含
# driver.find_element(By.CSS_SELECTOR,"a[href*='image.baidu.com']").click()
# 模糊匹配——匹配开头
# driver.find_element(By.CSS_SELECTOR,"a[href^='http://image.baidu']").click()
# 模糊匹配——匹配结尾
# driver.find_element(By.CSS_SELECTOR,"a[href$='image.baidu.com/']").click()
# 组合定位
driver.find_element(By.CSS_SELECTOR,"input.s_ipt").send_keys("selenium")


time.sleep(4)
driver.close()